package com.daidai.testsingleinstance

import android.app.Activity
import android.app.Application
import android.os.Bundle
import android.util.Log

fun androidLog(str:String){
    Log.e("MyLog",str)
}
class MyApp : Application() {

    override fun onCreate() {
        super.onCreate()

        androidLog("=======App pid:${android.os.Process.myPid()}")

        registerActivityLifecycleCallbacks(object: ActivityLifecycleCallbacks {
            override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
                androidLog("onActivityCreated : ${activity::class.java.simpleName}")
            }

            override fun onActivityStarted(activity: Activity) {
            }

            override fun onActivityResumed(activity: Activity) {
                androidLog("onActivityResumed : ${activity::class.java.simpleName}")
            }

            override fun onActivityPaused(activity: Activity) {
                androidLog("onActivityPaused : ${activity::class.java.simpleName}")
            }

            override fun onActivityStopped(activity: Activity) {
            }

            override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {
            }

            override fun onActivityDestroyed(activity: Activity) {
            }
        })
    }
}